<template>
	<view class="home">
		<button @click="click">点我啊</button>
		<view class="goods_list">
			<view class="goods_item" v-for="item in goods" :key="item.id" @click="navigator(item.id)">
				<image :src="item.img_url"></image>
				<view class="price">
					<text>￥{{item.sell_price}}</text>
					<text>￥{{item.market_price}}</text>
				</view>
				<view class="name">
					{{item.title}}
				</view>
			</view>
		</view>
</template>

<script>
	import global from '../../components/common.vue'
	export default {
		data() {
			return {
				msg: 'hello-uni',
				goods_list: [
					{ 
						goods_name: '梨子', 
						present_price: 1,
						original_price: 2,
						image: "/media/goods_images/%E6%A2%A8%E5%AD%90.png",
					},
					{
						goods_name: '香蕉', 
						present_price: 3,
						original_price: 4,
						image: "/media/goods_images/33333.png",
					},
					{
						goods_name: '"苹果"', 
						present_price: 7,
						original_price: 9,
						image: "/media/goods_images/q111.png",
					}
				],
			}
		},
		onLoad() {

		},
		methods: {
			async click () {
			    const res = await this.$myRequest({
			      method: 'GET',
			      url: '/api/store/goods/'
			    })
			    this.msg = "update goods data!"
				this.goods_list = res.data
				// for goods in goods_list:this.$myRequest
				for (var i=0;i<this.goods_list.length;i++)
				{ 
					var goods_i = this.goods_list[i]
				    // console.log( goods_i + "<br>");
					
					// console.log("this.$baseUrl   "  + this.$baseUrl)
					goods_i.image =  this.$baseUrl + goods_i.image
					console.log("image_url: "  +goods_i.image)
				}
			  },

		}
	}
</script>

<style>
	
</style>
